package com.xunfang.controller;

import com.xunfang.bean.House;
import com.xunfang.bean.QueryHouse;
import com.xunfang.bean.Result;
import com.xunfang.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author yellow Doctor
 * @date 2025-09-17
 * @desc https://blog.csdn.net/hekai7217
 */
@RestController
@RequestMapping("/house")
public class HouseController {

    @Autowired
    private HouseService houseService;

    // @RequestBody House house    前端页面发送的是json 格式化的数据
    // House house                 前端页面发送的是k-v  绑定数据
    // 或者使用@RequestParam  一个个的字段获取

    @GetMapping("/list")
    public Result selectAll(QueryHouse queryHouse){
        return Result.ok(houseService.selectAllHouse(queryHouse));
    }

    @PutMapping("")
    public Result updateHouse(@RequestBody House house){
        houseService.updateHouse(house);
        return Result.ok();
    }

}
